package decode;

public class Solution {
    public int[] decode(int[] encoded, int first) {
        int m = encoded.length;
        int []ans = new int[m+1];
        ans[0] = first;
        int a = first;
        int index = 1;
        for (int axorb: encoded) {
            int b = axorb^a;
            ans[index++] = b;
            a = b;
        }
        return ans;
    }
    // 1001
    // 1010 ^
    // 0011
    // 1001

    // 两次异或 a^b^b = a
    // 我们已经知道了 a^b 和 a 要求b
}
